#include "../s21_decimal.h"

#include <check.h>

START_TEST(add_0) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  s21_decimal sum = INIT_ZERO_S21_DECIMAL;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(sum.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(add_1) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 1;
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 1;
  s21_decimal sum = INIT_ZERO_S21_DECIMAL;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(sum.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(add_2) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 567;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 3456567;
  s21_set_sign(&second, NEGATIVE);
  s21_decimal sum = INIT_ZERO_S21_DECIMAL;
  sum.bits[0] = 3456000;
  s21_set_sign(&sum, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(sum.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(add_3) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 1;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  s21_decimal sum = INIT_ZERO_S21_DECIMAL;
  sum.bits[1] = 1;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(sum.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(add_4) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  s21_decimal sum = INIT_ZERO_S21_DECIMAL;
  sum.bits[0] = ALL_BIT - 1;
  sum.bits[1] = ALL_BIT;
  sum.bits[2] = 1;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(sum.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(add_5) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 1024512;
  s21_set_scale(&first, 3);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 60044444;
  s21_set_scale(&second, 5);
  s21_decimal sum = INIT_ZERO_S21_DECIMAL;
  sum.bits[0] = 162495644;
  s21_set_scale(&sum, 5);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(sum.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(add_6) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 6;
  s21_set_scale(&first, 1);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_decimal sum = INIT_ZERO_S21_DECIMAL;
  sum.bits[0] = ALL_BIT;
  sum.bits[1] = ALL_BIT;
  sum.bits[2] = ALL_BIT;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(sum.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(add_7) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  s21_set_scale(&second, 28);
  s21_decimal sum = INIT_ZERO_S21_DECIMAL;
  sum.bits[0] = ALL_BIT;
  sum.bits[1] = ALL_BIT;
  sum.bits[2] = ALL_BIT;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(sum.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(add_8) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 14;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 500;
  s21_set_scale(&second, 3);
  s21_decimal sum = INIT_ZERO_S21_DECIMAL;
  sum.bits[0] = 14;
  sum.bits[1] = ALL_BIT;
  sum.bits[2] = ALL_BIT;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(sum.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(add_9) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 14;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 51;
  s21_set_scale(&second, 2);
  s21_decimal sum = INIT_ZERO_S21_DECIMAL;
  sum.bits[0] = 15;
  sum.bits[1] = ALL_BIT;
  sum.bits[2] = ALL_BIT;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(sum.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(add_10) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_add(first, second, NULL), NAN_ERROR);
}
END_TEST

void add_add_tcase(Suite *suite) {
  TCase *add_tcase = tcase_create("add");
  tcase_add_test(add_tcase, add_0);
  tcase_add_test(add_tcase, add_1);
  tcase_add_test(add_tcase, add_2);
  tcase_add_test(add_tcase, add_3);
  tcase_add_test(add_tcase, add_4);
  tcase_add_test(add_tcase, add_5);
  tcase_add_test(add_tcase, add_6);
  tcase_add_test(add_tcase, add_7);
  tcase_add_test(add_tcase, add_8);
  tcase_add_test(add_tcase, add_9);
  tcase_add_test(add_tcase, add_10);
  suite_add_tcase(suite, add_tcase);
}

START_TEST(sub_0) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  s21_decimal difference = INIT_ZERO_S21_DECIMAL;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(difference.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(sub_1) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 3;
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 5;
  s21_set_sign(&second, NEGATIVE);
  s21_decimal difference = INIT_ZERO_S21_DECIMAL;
  difference.bits[0] = 2;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(difference.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(sub_2) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 753009;
  s21_set_scale(&first, 3);
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 82200321;
  s21_set_scale(&second, 5);
  s21_decimal difference = INIT_ZERO_S21_DECIMAL;
  difference.bits[0] = 157501221;
  s21_set_scale(&difference, 5);
  s21_set_sign(&difference, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(difference.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(sub_3) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[1] = ALL_BIT;
  s21_decimal difference = INIT_ZERO_S21_DECIMAL;
  difference.bits[0] = ALL_BIT;
  difference.bits[2] = ALL_BIT;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(difference.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(sub_4) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 3;
  s21_set_scale(&second, 1);
  s21_decimal difference = INIT_ZERO_S21_DECIMAL;
  difference.bits[0] = ALL_BIT;
  difference.bits[1] = ALL_BIT;
  difference.bits[2] = ALL_BIT;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(difference.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(sub_5) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 9;
  s21_set_scale(&second, 1);
  s21_decimal difference = INIT_ZERO_S21_DECIMAL;
  difference.bits[0] = ALL_BIT - 1;
  difference.bits[1] = ALL_BIT;
  difference.bits[2] = ALL_BIT;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(difference.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(sub_6) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 5;
  s21_set_scale(&second, 1);
  s21_decimal difference = INIT_ZERO_S21_DECIMAL;
  difference.bits[0] = ALL_BIT - 1;
  difference.bits[1] = ALL_BIT;
  difference.bits[2] = ALL_BIT;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(difference.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(sub_7) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT - 1;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 5;
  s21_set_scale(&second, 1);
  s21_decimal difference = INIT_ZERO_S21_DECIMAL;
  difference.bits[0] = ALL_BIT - 1;
  difference.bits[1] = ALL_BIT;
  difference.bits[2] = ALL_BIT;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(difference.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(sub_8) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_set_scale(&second, 28);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, &result), NEGATIVE_INF_ERROR);
}
END_TEST

START_TEST(sub_9) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  s21_set_scale(&second, 333);
  s21_set_sign(&second, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, &result), POSITIVE_INF_ERROR);
}
END_TEST

START_TEST(sub_10) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_sub(first, second, NULL), NAN_ERROR);
}
END_TEST

void add_sub_tcase(Suite *suite) {
  TCase *sub_tcase = tcase_create("sub");
  tcase_add_test(sub_tcase, sub_0);
  tcase_add_test(sub_tcase, sub_1);
  tcase_add_test(sub_tcase, sub_2);
  tcase_add_test(sub_tcase, sub_3);
  tcase_add_test(sub_tcase, sub_4);
  tcase_add_test(sub_tcase, sub_5);
  tcase_add_test(sub_tcase, sub_6);
  tcase_add_test(sub_tcase, sub_7);
  tcase_add_test(sub_tcase, sub_8);
  tcase_add_test(sub_tcase, sub_9);
  tcase_add_test(sub_tcase, sub_10);
  suite_add_tcase(suite, sub_tcase);
}

START_TEST(mul_by_ten_1) {
  s21_long_decimal first = INIT_ZERO_S21_LONG_DECIMAL;
  s21_long_decimal mul_by_ten_first = INIT_ZERO_S21_LONG_DECIMAL;

  s21_mul_long_by_ten(&first);

  for (int i = 0; i <= LONG_LAST; i++) {
    ck_assert_int_eq(first.bits[i], mul_by_ten_first.bits[i]);
  }
}
END_TEST

START_TEST(mul_by_ten_2) {
  s21_long_decimal first = INIT_ZERO_S21_LONG_DECIMAL;
  first.bits[0] = 55;
  s21_long_decimal mul_by_ten_first = INIT_ZERO_S21_LONG_DECIMAL;
  mul_by_ten_first.bits[0] = 550;

  s21_mul_long_by_ten(&first);

  for (int i = 0; i <= LONG_LAST; i++) {
    ck_assert_int_eq(first.bits[i], mul_by_ten_first.bits[i]);
  }
}
END_TEST

START_TEST(mul_by_ten_3) {
  s21_long_decimal first = INIT_ZERO_S21_LONG_DECIMAL;
  first.bits[1] = 123;
  s21_set_long_sign(&first, NEGATIVE);
  s21_long_decimal mul_by_ten_first = INIT_ZERO_S21_LONG_DECIMAL;
  mul_by_ten_first.bits[1] = 1230;
  s21_set_long_sign(&mul_by_ten_first, NEGATIVE);

  s21_mul_long_by_ten(&first);

  for (int i = 0; i <= LONG_LAST; i++) {
    ck_assert_int_eq(first.bits[i], mul_by_ten_first.bits[i]);
  }
}
END_TEST

void add_mul_by_ten_tcase(Suite *suite) {
  TCase *mul_by_ten_tcase = tcase_create("mul_by_ten");
  tcase_add_test(mul_by_ten_tcase, mul_by_ten_1);
  tcase_add_test(mul_by_ten_tcase, mul_by_ten_2);
  tcase_add_test(mul_by_ten_tcase, mul_by_ten_3);
  suite_add_tcase(suite, mul_by_ten_tcase);
}

START_TEST(mul_0) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 62;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 48;
  s21_decimal composition = INIT_ZERO_S21_DECIMAL;
  composition.bits[0] = 2976;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(composition.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(mul_1) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[1] = 83;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 1;
  s21_decimal composition = INIT_ZERO_S21_DECIMAL;
  composition.bits[1] = 83;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(composition.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(mul_2) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  s21_decimal composition = INIT_ZERO_S21_DECIMAL;
  s21_set_sign(&composition, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(composition.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(mul_3) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[1] = 83;
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 10;
  s21_set_scale(&second, 1);
  s21_decimal composition = INIT_ZERO_S21_DECIMAL;
  composition.bits[1] = 830;
  s21_set_scale(&composition, 1);
  s21_set_sign(&composition, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(composition.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(mul_4) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_set_sign(&second, NEGATIVE);
  s21_decimal composition = INIT_ZERO_S21_DECIMAL;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(composition.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(mul_5) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 115904;
  s21_set_sign(&first, NEGATIVE);
  s21_set_scale(&first, 2);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 785;
  s21_set_scale(&second, 1);
  s21_decimal composition = INIT_ZERO_S21_DECIMAL;
  composition.bits[0] = 90984640;
  s21_set_sign(&composition, NEGATIVE);
  s21_set_scale(&composition, 3);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(composition.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(mul_6) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  // 26409387504754779197847983445
  first.bits[0] = 0b01010101010101010101010101010101;
  first.bits[1] = 0b01010101010101010101010101010101;
  first.bits[2] = 0b01010101010101010101010101010101;
  s21_set_scale(&first, 21);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 5;
  s21_set_scale(&second, 16);
  s21_decimal composition = INIT_ZERO_S21_DECIMAL;
  // 132046937523773895989
  composition.bits[0] = 0b00101110101111011111010100110101;
  composition.bits[1] = 0b00101000100001001111011000010000;
  composition.bits[2] = 0b00000000000000000000000000000111;
  s21_set_scale(&composition, 28);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(composition.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(mul_7) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 2032156321;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 1200555987;
  s21_decimal composition = INIT_ZERO_S21_DECIMAL;
  // composition = 2439717437696443827
  composition.bits[0] = 0b01011010001110010000010110110011;
  composition.bits[1] = 0b00100001110110111001111000010101;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(composition.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(mul_8) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[2] = ALL_BIT;
  s21_set_scale(&first, 28);
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_set_sign(&second, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, &result), POSITIVE_INF_ERROR);
}
END_TEST

START_TEST(mul_9) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_set_scale(&second, 28);
  s21_set_sign(&second, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, &result), NEGATIVE_INF_ERROR);
}
END_TEST

START_TEST(mul_10) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_mul(first, second, NULL), NAN_ERROR);
}
END_TEST

void add_mul_tcase(Suite *suite) {
  TCase *mul_tcase = tcase_create("mul");
  tcase_add_test(mul_tcase, mul_0);
  tcase_add_test(mul_tcase, mul_1);
  tcase_add_test(mul_tcase, mul_2);
  tcase_add_test(mul_tcase, mul_3);
  tcase_add_test(mul_tcase, mul_4);
  tcase_add_test(mul_tcase, mul_5);
  tcase_add_test(mul_tcase, mul_6);
  tcase_add_test(mul_tcase, mul_7);
  tcase_add_test(mul_tcase, mul_8);
  tcase_add_test(mul_tcase, mul_9);
  tcase_add_test(mul_tcase, mul_10);
  suite_add_tcase(suite, mul_tcase);
}

START_TEST(div_0) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 123;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;  // zero
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_div(first, second, &result), NAN_ERROR);
}
END_TEST

START_TEST(div_1) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 321;
  s21_decimal quotient = INIT_ZERO_S21_DECIMAL;
  s21_set_sign(&quotient, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_div(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(quotient.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(div_2) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 36;
  s21_set_scale(&first, 25);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 24;
  s21_set_scale(&second, 25);
  s21_decimal quotient = INIT_ZERO_S21_DECIMAL;
  quotient.bits[0] = 15;
  s21_set_scale(&quotient, 1);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_div(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(quotient.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(div_3) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 93074;
  s21_set_scale(&first, 2);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 173;
  s21_set_scale(&second, 1);
  s21_decimal quotient = INIT_ZERO_S21_DECIMAL;
  quotient.bits[0] = 538;
  s21_set_scale(&quotient, 1);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  ck_assert_int_eq(s21_div(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(quotient.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(div_4) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 254;
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 640;
  s21_decimal quotient = INIT_ZERO_S21_DECIMAL;
  quotient.bits[0] = 396875;
  s21_set_scale(&quotient, 6);
  s21_set_sign(&quotient, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_div(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(quotient.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(div_5) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 89;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 25;
  s21_set_scale(&second, 1);
  s21_set_sign(&second, NEGATIVE);
  s21_decimal quotient = INIT_ZERO_S21_DECIMAL;
  quotient.bits[0] = 356;
  s21_set_scale(&quotient, 1);
  s21_set_sign(&quotient, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_div(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(quotient.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(div_6) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[1] = 1 << 28;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 8;
  s21_decimal quotient = INIT_ZERO_S21_DECIMAL;
  quotient.bits[1] = 1 << 25;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  ck_assert_int_eq(s21_div(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(quotient.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(div_7) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[2] = ALL_BIT - 1;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[2] = 2147483647;
  s21_decimal quotient = INIT_ZERO_S21_DECIMAL;
  quotient.bits[0] = 2;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_div(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(quotient.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(div_8) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_set_sign(&first, NEGATIVE);
  s21_set_scale(&first, 5);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_set_scale(&second, 14);
  s21_decimal quotient = INIT_ZERO_S21_DECIMAL;
  quotient.bits[0] = 1000000000;
  s21_set_sign(&quotient, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_div(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(quotient.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(div_9) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_set_sign(&first, NEGATIVE);
  s21_set_scale(&first, 5);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_set_scale(&second, 3);
  s21_decimal quotient = INIT_ZERO_S21_DECIMAL;
  quotient.bits[0] = 1;
  s21_set_sign(&quotient, NEGATIVE);
  s21_set_scale(&quotient, 2);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_div(first, second, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(quotient.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(div_10) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_div(first, second, NULL), NAN_ERROR);
}
END_TEST

void add_div_tcase(Suite *suite) {
  TCase *div_tcase = tcase_create("div");
  tcase_add_test(div_tcase, div_0);
  tcase_add_test(div_tcase, div_1);
  tcase_add_test(div_tcase, div_2);
  tcase_add_test(div_tcase, div_3);
  tcase_add_test(div_tcase, div_4);
  tcase_add_test(div_tcase, div_5);
  tcase_add_test(div_tcase, div_6);
  tcase_add_test(div_tcase, div_7);
  tcase_add_test(div_tcase, div_8);
  tcase_add_test(div_tcase, div_9);
  tcase_add_test(div_tcase, div_10);
  suite_add_tcase(suite, div_tcase);
}

START_TEST(negate_0) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 1;
  s21_decimal negate_value = INIT_ZERO_S21_DECIMAL;
  negate_value.bits[0] = 1;
  s21_set_sign(&negate_value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_negate(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(negate_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(negate_1) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[2] = 1;
  s21_set_sign(&value, NEGATIVE);
  s21_decimal negate_value = INIT_ZERO_S21_DECIMAL;
  negate_value.bits[2] = 1;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_negate(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(negate_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(negate_2) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = ALL_BIT;
  value.bits[1] = ALL_BIT;
  value.bits[2] = ALL_BIT;
  s21_decimal negate_value = INIT_ZERO_S21_DECIMAL;
  negate_value.bits[0] = ALL_BIT;
  negate_value.bits[1] = ALL_BIT;
  negate_value.bits[2] = ALL_BIT;
  s21_set_sign(&negate_value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_negate(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(negate_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(negate_3) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_negate(value, NULL), ERROR);
}
END_TEST

void add_negate_tcase(Suite *suite) {
  TCase *negate_tcase = tcase_create("negate");
  tcase_add_test(negate_tcase, negate_0);
  tcase_add_test(negate_tcase, negate_1);
  tcase_add_test(negate_tcase, negate_2);
  tcase_add_test(negate_tcase, negate_3);
  suite_add_tcase(suite, negate_tcase);
}

START_TEST(truncate_0) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  s21_decimal truncate_value = INIT_ZERO_S21_DECIMAL;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_truncate(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(truncate_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(truncate_1) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[2] = ALL_BIT;
  s21_decimal truncate_value = INIT_ZERO_S21_DECIMAL;
  truncate_value.bits[2] = ALL_BIT;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_truncate(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(truncate_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(truncate_2) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 150000;
  s21_set_scale(&value, 5);
  s21_decimal truncate_value = INIT_ZERO_S21_DECIMAL;
  truncate_value.bits[0] = 1;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_truncate(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(truncate_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(truncate_3) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 400000000;
  s21_set_scale(&value, 7);
  s21_set_sign(&value, NEGATIVE);
  s21_decimal truncate_value = INIT_ZERO_S21_DECIMAL;
  truncate_value.bits[0] = 40;
  s21_set_sign(&truncate_value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_truncate(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(truncate_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(truncate_4) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = ALL_BIT;
  value.bits[1] = ALL_BIT;
  value.bits[2] = ALL_BIT;
  s21_set_scale(&value, 28);
  s21_decimal truncate_value = INIT_ZERO_S21_DECIMAL;
  truncate_value.bits[0] = 7;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_truncate(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(truncate_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(truncate_5) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_truncate(value, NULL), ERROR);
}
END_TEST

void add_truncate_tcase(Suite *suite) {
  TCase *truncate_tcase = tcase_create("truncate");
  tcase_add_test(truncate_tcase, truncate_0);
  tcase_add_test(truncate_tcase, truncate_1);
  tcase_add_test(truncate_tcase, truncate_2);
  tcase_add_test(truncate_tcase, truncate_3);
  tcase_add_test(truncate_tcase, truncate_4);
  tcase_add_test(truncate_tcase, truncate_5);
  suite_add_tcase(suite, truncate_tcase);
}

START_TEST(round_0) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 1;
  s21_decimal round_value = INIT_ZERO_S21_DECIMAL;
  round_value.bits[0] = 1;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_round(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(round_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(round_1) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 250000;
  s21_set_scale(&value, 5);
  s21_decimal round_value = INIT_ZERO_S21_DECIMAL;
  round_value.bits[0] = 2;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_round(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(round_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(round_2) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 56888;
  s21_set_scale(&value, 2);
  s21_decimal round_value = INIT_ZERO_S21_DECIMAL;
  round_value.bits[0] = 569;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_round(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(round_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(round_3) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = ALL_BIT;
  value.bits[1] = ALL_BIT;
  s21_set_sign(&value, NEGATIVE);
  s21_set_scale(&value, 28);
  s21_decimal round_value = INIT_ZERO_S21_DECIMAL;
  s21_set_sign(&round_value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_round(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(round_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(round_4) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = ALL_BIT;
  value.bits[1] = ALL_BIT;
  value.bits[2] = ALL_BIT;
  s21_set_sign(&value, NEGATIVE);
  s21_set_scale(&value, 28);
  s21_decimal round_value = INIT_ZERO_S21_DECIMAL;
  round_value.bits[0] = 8;
  s21_set_sign(&round_value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_round(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(round_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(round_5) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_round(value, NULL), ERROR);
}
END_TEST

void add_round_tcase(Suite *suite) {
  TCase *round_tcase = tcase_create("round");
  tcase_add_test(round_tcase, round_0);
  tcase_add_test(round_tcase, round_1);
  tcase_add_test(round_tcase, round_2);
  tcase_add_test(round_tcase, round_3);
  tcase_add_test(round_tcase, round_4);
  tcase_add_test(round_tcase, round_5);
  suite_add_tcase(suite, round_tcase);
}

START_TEST(floor_0) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 1;
  s21_set_sign(&value, NEGATIVE);
  s21_decimal floor_value = INIT_ZERO_S21_DECIMAL;
  floor_value.bits[0] = 1;
  s21_set_sign(&floor_value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_floor(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(floor_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(floor_1) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 56;
  s21_set_scale(&value, 1);
  s21_decimal floor_value = INIT_ZERO_S21_DECIMAL;
  floor_value.bits[0] = 5;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_floor(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(floor_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(floor_2) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 99999999;
  s21_set_scale(&value, 8);
  s21_decimal floor_value = INIT_ZERO_S21_DECIMAL;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_floor(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(floor_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(floor_3) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = ALL_BIT;
  value.bits[1] = ALL_BIT;
  s21_set_scale(&value, 28);
  s21_set_sign(&value, NEGATIVE);
  s21_decimal floor_value = INIT_ZERO_S21_DECIMAL;
  floor_value.bits[0] = 1;
  s21_set_sign(&floor_value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_floor(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(floor_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(floor_4) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = ALL_BIT;
  value.bits[1] = ALL_BIT;
  value.bits[2] = ALL_BIT;
  s21_set_sign(&value, NEGATIVE);
  s21_decimal floor_value = INIT_ZERO_S21_DECIMAL;
  floor_value.bits[0] = ALL_BIT;
  floor_value.bits[1] = ALL_BIT;
  floor_value.bits[2] = ALL_BIT;
  s21_set_sign(&floor_value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_floor(value, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(floor_value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(floor_5) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_floor(value, NULL), ERROR);
}
END_TEST

void add_floor_tcase(Suite *suite) {
  TCase *floor_tcase = tcase_create("floor");
  tcase_add_test(floor_tcase, floor_0);
  tcase_add_test(floor_tcase, floor_1);
  tcase_add_test(floor_tcase, floor_2);
  tcase_add_test(floor_tcase, floor_3);
  tcase_add_test(floor_tcase, floor_4);
  tcase_add_test(floor_tcase, floor_5);
  suite_add_tcase(suite, floor_tcase);
}

START_TEST(compare_0) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  s21_set_sign(&second, NEGATIVE);

  ck_assert_int_eq(s21_is_less(first, second), FALSE);
  ck_assert_int_eq(s21_is_less_or_equal(first, second), TRUE);
  ck_assert_int_eq(s21_is_greater(first, second), FALSE);
  ck_assert_int_eq(s21_is_greater_or_equal(first, second), TRUE);
  ck_assert_int_eq(s21_is_equal(first, second), TRUE);
  ck_assert_int_eq(s21_is_not_equal(first, second), FALSE);
}
END_TEST

START_TEST(compare_1) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_set_scale(&first, 16);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_set_scale(&second, 24);

  ck_assert_int_eq(s21_is_less(first, second), FALSE);
  ck_assert_int_eq(s21_is_less_or_equal(first, second), FALSE);
  ck_assert_int_eq(s21_is_greater(first, second), TRUE);
  ck_assert_int_eq(s21_is_greater_or_equal(first, second), TRUE);
  ck_assert_int_eq(s21_is_equal(first, second), FALSE);
  ck_assert_int_eq(s21_is_not_equal(first, second), TRUE);
}
END_TEST

START_TEST(compare_2) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = 56000;
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = 1;

  ck_assert_int_eq(s21_is_less(first, second), TRUE);
  ck_assert_int_eq(s21_is_less_or_equal(first, second), TRUE);
  ck_assert_int_eq(s21_is_greater(first, second), FALSE);
  ck_assert_int_eq(s21_is_greater_or_equal(first, second), FALSE);
  ck_assert_int_eq(s21_is_equal(first, second), FALSE);
  ck_assert_int_eq(s21_is_not_equal(first, second), TRUE);
}
END_TEST

START_TEST(compare_3) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT - 1;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_set_sign(&first, NEGATIVE);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_set_sign(&second, NEGATIVE);

  ck_assert_int_eq(s21_is_less(first, second), FALSE);
  ck_assert_int_eq(s21_is_less_or_equal(first, second), FALSE);
  ck_assert_int_eq(s21_is_greater(first, second), TRUE);
  ck_assert_int_eq(s21_is_greater_or_equal(first, second), TRUE);
  ck_assert_int_eq(s21_is_equal(first, second), FALSE);
  ck_assert_int_eq(s21_is_not_equal(first, second), TRUE);
}
END_TEST

START_TEST(compare_4) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT - 1;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_set_scale(&first, 28);
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_set_scale(&second, 28);

  ck_assert_int_eq(s21_is_less(first, second), TRUE);
  ck_assert_int_eq(s21_is_less_or_equal(first, second), TRUE);
  ck_assert_int_eq(s21_is_greater(first, second), FALSE);
  ck_assert_int_eq(s21_is_greater_or_equal(first, second), FALSE);
  ck_assert_int_eq(s21_is_equal(first, second), FALSE);
  ck_assert_int_eq(s21_is_not_equal(first, second), TRUE);
}
END_TEST

START_TEST(compare_5) {
  s21_decimal first = INIT_ZERO_S21_DECIMAL;
  first.bits[0] = ALL_BIT;
  first.bits[1] = ALL_BIT;
  first.bits[2] = ALL_BIT;
  s21_decimal second = INIT_ZERO_S21_DECIMAL;
  second.bits[0] = ALL_BIT;
  second.bits[1] = ALL_BIT;
  second.bits[2] = ALL_BIT;
  s21_set_sign(&second, NEGATIVE);

  ck_assert_int_eq(s21_is_less(first, second), FALSE);
  ck_assert_int_eq(s21_is_less_or_equal(first, second), FALSE);
  ck_assert_int_eq(s21_is_greater(first, second), TRUE);
  ck_assert_int_eq(s21_is_greater_or_equal(first, second), TRUE);
  ck_assert_int_eq(s21_is_equal(first, second), FALSE);
  ck_assert_int_eq(s21_is_not_equal(first, second), TRUE);
}
END_TEST

START_TEST(compare_6) { ck_assert_int_eq(s21_compare(NULL, NULL), FALSE); }
END_TEST

void add_compare_tcase(Suite *suite) {
  TCase *compare_tcase = tcase_create("compare");
  tcase_add_test(compare_tcase, compare_0);
  tcase_add_test(compare_tcase, compare_1);
  tcase_add_test(compare_tcase, compare_2);
  tcase_add_test(compare_tcase, compare_3);
  tcase_add_test(compare_tcase, compare_4);
  tcase_add_test(compare_tcase, compare_5);
  tcase_add_test(compare_tcase, compare_6);
  suite_add_tcase(suite, compare_tcase);
}

START_TEST(init_0) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[LAST] = ALL_BIT;

  ck_assert_int_eq(s21_is_invalid(&value), TRUE);
}
END_TEST

START_TEST(init_1) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[LAST] = 0b00000000000111110000000000000000;

  ck_assert_int_eq(s21_is_valid(&value), FALSE);
}
END_TEST

void add_init_tcase(Suite *suite) {
  TCase *init_tcase = tcase_create("init");
  tcase_add_test(init_tcase, init_0);
  tcase_add_test(init_tcase, init_1);
  suite_add_tcase(suite, init_tcase);
}

START_TEST(int_to_decimal_0) {
  int number = -1;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 1;
  s21_set_sign(&value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_from_int_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(int_to_decimal_1) {
  int number = INT_MAX;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = ALL_BIT >> 1;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_from_int_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(int_to_decimal_2) {
  int number = INT_MIN;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 1 << 31;
  s21_set_sign(&value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_from_int_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(int_to_decimal_3) {
  int number = 321123;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 321123;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_from_int_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(int_to_decimal_4) {
  int number = -2147483647;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 2147483647;
  s21_set_sign(&value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_from_int_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }
}
END_TEST

START_TEST(int_to_decimal_5) {
  int number = 0;

  ck_assert_int_eq(s21_from_int_to_decimal(number, NULL), ERROR);
}
END_TEST

void add_int_to_decimal_tcase(Suite *suite) {
  TCase *int_to_decimal_tcase = tcase_create("int_to_decimal");
  tcase_add_test(int_to_decimal_tcase, int_to_decimal_0);
  tcase_add_test(int_to_decimal_tcase, int_to_decimal_1);
  tcase_add_test(int_to_decimal_tcase, int_to_decimal_2);
  tcase_add_test(int_to_decimal_tcase, int_to_decimal_3);
  tcase_add_test(int_to_decimal_tcase, int_to_decimal_4);
  tcase_add_test(int_to_decimal_tcase, int_to_decimal_5);
  suite_add_tcase(suite, int_to_decimal_tcase);
}

START_TEST(decimal_to_int_0) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 0;
  s21_set_sign(&value, NEGATIVE);
  int number = 0;
  int result = 0;

  ck_assert_int_eq(s21_from_decimal_to_int(value, &result), OK);
  ck_assert_int_eq(number, result);
}
END_TEST

START_TEST(decimal_to_int_1) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 2147483647;
  int number = INT_MAX;
  int result = 0;

  ck_assert_int_eq(s21_from_decimal_to_int(value, &result), OK);
  ck_assert_int_eq(number, result);
}
END_TEST

START_TEST(decimal_to_int_2) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 1 << 31;
  s21_set_sign(&value, NEGATIVE);
  int number = -2147483648;
  int result = 0;

  ck_assert_int_eq(s21_from_decimal_to_int(value, &result), OK);
  ck_assert_int_eq(number, result);
}
END_TEST

START_TEST(decimal_to_int_3) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 1 << 31;
  int result = 0;

  ck_assert_int_eq(s21_from_decimal_to_int(value, &result), ERROR);
}
END_TEST

START_TEST(decimal_to_int_4) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = ALL_BIT;
  s21_set_sign(&value, NEGATIVE);
  int result = 0;

  ck_assert_int_eq(s21_from_decimal_to_int(value, &result), ERROR);
}
END_TEST

START_TEST(decimal_to_int_5) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[1] = 5;
  int result = 0;

  ck_assert_int_eq(s21_from_decimal_to_int(value, &result), ERROR);
}
END_TEST

void add_decimal_to_int_tcase(Suite *suite) {
  TCase *decimal_to_int_tcase = tcase_create("decimal_to_int");
  tcase_add_test(decimal_to_int_tcase, decimal_to_int_0);
  tcase_add_test(decimal_to_int_tcase, decimal_to_int_1);
  tcase_add_test(decimal_to_int_tcase, decimal_to_int_2);
  tcase_add_test(decimal_to_int_tcase, decimal_to_int_3);
  tcase_add_test(decimal_to_int_tcase, decimal_to_int_4);
  tcase_add_test(decimal_to_int_tcase, decimal_to_int_5);
  suite_add_tcase(suite, decimal_to_int_tcase);
}

START_TEST(decimal_to_float_0) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 1;
  s21_set_sign(&value, NEGATIVE);
  float number = -1.0;
  float result = 0.0;

  ck_assert_int_eq(s21_from_decimal_to_float(value, &result), OK);
  ck_assert_float_eq_tol(number, result, EPSILON);
}
END_TEST

START_TEST(decimal_to_float_1) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  // 132046937523773895989
  value.bits[0] = 0b00101110101111011111010100110101;
  value.bits[1] = 0b00101000100001001111011000010000;
  value.bits[2] = 0b00000000000000000000000000000111;
  s21_set_scale(&value, 15);
  float number = 132046.937523773895989;
  float result = 0.0;

  ck_assert_int_eq(s21_from_decimal_to_float(value, &result), OK);
  ck_assert_float_eq_tol(number, result, EPSILON);
}
END_TEST

START_TEST(decimal_to_float_2) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  // 2439717437696443827
  value.bits[0] = 0b01011010001110010000010110110011;
  value.bits[1] = 0b00100001110110111001111000010101;
  s21_set_sign(&value, NEGATIVE);
  float number = -2439717437696443827.0;
  float result = 0.0;

  ck_assert_int_eq(s21_from_decimal_to_float(value, &result), OK);
  ck_assert_float_eq_tol(number, result, EPSILON);
}
END_TEST

START_TEST(decimal_to_float_3) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = ALL_BIT;
  value.bits[1] = ALL_BIT;
  value.bits[2] = ALL_BIT;
  s21_set_sign(&value, NEGATIVE);
  float number = -7.9228162514264E+28;
  float result = 0.0;

  ck_assert_int_eq(s21_from_decimal_to_float(value, &result), OK);
  ck_assert_float_eq_tol(number, result, EPSILON);
}
END_TEST

START_TEST(decimal_to_float_4) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = ALL_BIT;
  value.bits[1] = ALL_BIT;
  value.bits[2] = ALL_BIT;
  s21_set_scale(&value, 28);
  float number = 7.9228162514264;
  float result = 0.0;

  ck_assert_int_eq(s21_from_decimal_to_float(value, &result), OK);
  ck_assert_float_eq_tol(number, result, EPSILON);
}
END_TEST

START_TEST(decimal_to_float_5) {
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[3] = ALL_BIT;
  float result = 0.0;

  ck_assert_int_eq(s21_from_decimal_to_float(value, &result), ERROR);
}
END_TEST

void add_decimal_to_float_tcase(Suite *suite) {
  TCase *decimal_to_float_tcase = tcase_create("decimal_to_float");
  tcase_add_test(decimal_to_float_tcase, decimal_to_float_0);
  tcase_add_test(decimal_to_float_tcase, decimal_to_float_1);
  tcase_add_test(decimal_to_float_tcase, decimal_to_float_2);
  tcase_add_test(decimal_to_float_tcase, decimal_to_float_3);
  tcase_add_test(decimal_to_float_tcase, decimal_to_float_4);
  tcase_add_test(decimal_to_float_tcase, decimal_to_float_5);
  suite_add_tcase(suite, decimal_to_float_tcase);
}

START_TEST(float_to_decimal_0) {
  float number = -123.0;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 123;
  s21_set_sign(&value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  float float_result = 0.0;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }

  ck_assert_int_eq(s21_from_decimal_to_float(result, &float_result), OK);
  ck_assert_float_eq_tol(number, float_result, EPSILON);
}
END_TEST

START_TEST(float_to_decimal_1) {
  float number = NAN;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), ERROR);
}
END_TEST

START_TEST(float_to_decimal_2) {
  float number = INFINITY;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), ERROR);
}
END_TEST

START_TEST(float_to_decimal_3) {
  float number = 9E+28;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), ERROR);
}
END_TEST

START_TEST(float_to_decimal_4) {
  float number = -1E-30;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 0;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  float float_result = 0.0;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), ERROR);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }

  ck_assert_int_eq(s21_from_decimal_to_float(result, &float_result), OK);
  ck_assert_float_eq_tol(number, float_result, EPSILON);
}
END_TEST

START_TEST(float_to_decimal_5) {
  float number = 1234567890;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 1234568000;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  float float_result = 0.0;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }

  ck_assert_int_eq(s21_from_decimal_to_float(result, &float_result), OK);
  ck_assert_float_eq_tol(number, float_result, EPSILON);
}
END_TEST

START_TEST(float_to_decimal_6) {
  float number = 599E-8;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 599;
  s21_set_scale(&value, 8);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  float float_result = 0.0;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }

  ck_assert_int_eq(s21_from_decimal_to_float(result, &float_result), OK);
  ck_assert_float_eq_tol(number, float_result, EPSILON);
}
END_TEST

START_TEST(float_to_decimal_7) {
  float number = -862.00005;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 8620001;
  s21_set_scale(&value, 4);
  s21_set_sign(&value, NEGATIVE);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  float float_result = 0.0;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }

  ck_assert_int_eq(s21_from_decimal_to_float(result, &float_result), OK);
  ck_assert_float_eq_tol(number, float_result, EPSILON);
}
END_TEST

START_TEST(float_to_decimal_8) {
  float number = 75000.57;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 7500057;
  s21_set_scale(&value, 2);
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  float float_result = 0.0;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }

  ck_assert_int_eq(s21_from_decimal_to_float(result, &float_result), OK);
  ck_assert_float_eq_tol(number, float_result, EPSILON);
}
END_TEST

START_TEST(float_to_decimal_9) {
  float number = 312E+09;
  s21_decimal value = INIT_ZERO_S21_DECIMAL;
  value.bits[0] = 0b10100100101001100011000000000000;
  value.bits[1] = 0b00000000000000000000000001001000;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  float float_result = 0.0;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), OK);

  for (int i = 0; i <= LAST; i++) {
    ck_assert_int_eq(value.bits[i], result.bits[i]);
  }

  ck_assert_int_eq(s21_from_decimal_to_float(result, &float_result), OK);
  ck_assert_float_eq_tol(number, float_result, EPSILON);
}
END_TEST

START_TEST(float_to_decimal_10) {
  float number = 7.922816E+28;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  float float_result = 0.0;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), OK);
  ck_assert_int_eq(s21_from_decimal_to_float(result, &float_result), OK);
  ck_assert_float_eq_tol(number, float_result, EPSILON);
}
END_TEST

START_TEST(float_to_decimal_11) {
  float number = -7.922816E+28;
  s21_decimal result = INIT_ZERO_S21_DECIMAL;
  float float_result = 0.0;

  ck_assert_int_eq(s21_from_float_to_decimal(number, &result), OK);
  ck_assert_int_eq(s21_from_decimal_to_float(result, &float_result), OK);
  ck_assert_float_eq_tol(number, float_result, EPSILON);
}
END_TEST

void add_float_to_decimal_tcase(Suite *suite) {
  TCase *float_to_decimal_tcase = tcase_create("float_to_decimal");
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_0);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_1);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_2);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_3);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_4);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_5);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_6);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_7);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_8);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_9);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_10);
  tcase_add_test(float_to_decimal_tcase, float_to_decimal_11);
  suite_add_tcase(suite, float_to_decimal_tcase);
}

Suite *get_suite(void) {
  Suite *suite = suite_create("_____ S21_DECIMAL_H TEST ______");

  add_add_tcase(suite);
  add_sub_tcase(suite);
  add_mul_by_ten_tcase(suite);
  add_mul_tcase(suite);
  add_div_tcase(suite);
  add_negate_tcase(suite);
  add_truncate_tcase(suite);
  add_round_tcase(suite);
  add_floor_tcase(suite);
  add_compare_tcase(suite);
  add_init_tcase(suite);
  add_int_to_decimal_tcase(suite);
  add_decimal_to_int_tcase(suite);
  add_decimal_to_float_tcase(suite);
  add_float_to_decimal_tcase(suite);

  return suite;
}

int main(void) {
  Suite *suite = get_suite();
  SRunner *suite_runner = srunner_create(suite);

  srunner_set_fork_status(suite_runner, CK_NOFORK);
  srunner_run_all(suite_runner, CK_NORMAL);

  int failed_count = srunner_ntests_failed(suite_runner);

  srunner_free(suite_runner);

  return failed_count == 0 ? OK : ERROR;
}